package com.chen.config;

import cn.dev33.satoken.interceptor.SaAnnotationInterceptor;
import cn.dev33.satoken.interceptor.SaRouteInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置sa-token拦截器
 */
@Configuration
public class SaTokenConfigure implements WebMvcConfigurer {

    // 注册拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册 Sa-Token 的路由拦截器
        registry.addInterceptor(new SaRouteInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/**","/file/editor/load","/files/**","/exam/**","/demo/**","/question/downloadTemplate",
                        "/question/import","/question/export","/file/**","/sys/**","/log/**","/file/**",
                        "/test/**","/user/**", "/swagger-resources/**", "/swagger-ui/**", "/v3/**", "/error")
                .excludePathPatterns("/**","/**/*.js","/**/**/*.css","/**/**/*.jpg","/**/**/*.png","/**/*.html",
                        "/**/**/*.js", "/**/**/*.css", "/**/**/*.woff", "/**/**/*.ttf","/**/*.ico");  // 放行静态文件
    }
}
